SQL Visualizer

ABSTRACT

A SQL Visualizer including means for transforming a textual SQL statement into a graphical diagram which represents the textual SQL statement.

FIELD

The invention relates to the conversion of the textual representation of database SQL statements and procedures into a graphical representation. The purpose of this process is to present the database statements and procedures in a form which is much closer to the logical structure of the underlying process, easier to manipulate, more transparent as to its function and less prone to erroneous development.

The features described herein can be implemented as a part of Microgen Aptitude V4.1-a program with a graphical interface which allows users to create complex applications without knowledge of traditional programming languages.

BACKGROUND

It is important that developers are able to easily see the logical structure of database SQL statements and procedures as it makes their work faster, more effective and less error prone. The current textual representation of SQL statements and procedures is difficult to understand due in part to the declarative nature of the language and the rather awkward syntax.

In practice, SQL statements and procedures are often very long, containing hundreds or even thousands of lines of text; this makes code analysis very difficult and time consuming. Moreover, the textual representation is frequently obscure and it is difficult to understand the function of the code.

We provide a way to make working with SQL statements and procedures easier, faster and less error prone by transforming SQL from its textual form into diagrams. The “language” underlying these diagrams has been designed to describe all aspects of the SQL language in a clear and unambiguous manner and, moreover, to allow the SQL to be structured in a manner which makes the underlying logic very clear. For example, text based SQL places the end result of the statement (insert into . . . for example) at the beginning while we provide a diagrammatic language which allows it to be placed at the end.

Modification of the code is much easier when the graphic language is used because the logic is transparent. It is also much easier to group the entities within a diagram so that the structure of the program can be very readily seen, in contrast for example to a long SQL program with little visual segmentation or structuring.

The features described herein make it possible to switch between the textual and graphical representations in either direction so the results of changes can be readily seen. To achieve this we provide a product which has two converters: “SQL Text to SQL Diagram” and “SQL Diagram to SQL Text”. The latter converter is the subject of the applicant's U.S. patent application Ser. No. 12/648,660, published as US 2011/1611371, the entire contents of which are incorporated by reference herein, which includes a description of Aptitude SQL Rules and Aptitude SQL Procedures. Note that this allows changes to the program to be made to either representation, i.e. textual or graphical, and then the other representation is re-generated.

The product described herein is not limited to the visualization of SQL Statements but also covers the Database procedures which are written in languages proprietary to the database, e.g. PL/SQL for Oracle. The product described herein understands the SQL Procedures languages for Oracle, Microsoft SQL Server and Teradata V14, at least.

SUMMARY

In one embodiment the invention provides a SQL Visualizer comprising means for transforming a textual SQL statement into a graphical diagram which represents the textual SQL statement.

The invention may also include any of the following features, which may be combined in any combination.

The graphical diagram which represents the textual SQL statement may be an Aptitude SQL Rule.

The SQL Visualizer may further comprises means for transforming a textual DML statement into a graphical diagram which represents the textual DML statement.

The graphical diagram which represents the textual DML statement may be an Aptitude SQL Rule.

The graphical diagram which represents the textual SQL statement and the graphical diagram which represents the textual DML statement may be both contained in the same Aptitude SQL Rule.

The SQL Visualizer may further comprise means for transforming a textual SQL procedure into a graphical diagram which represents the textual SQL procedure.

The graphical diagram which represents the textual SQL procedure may be an Aptitude SQL Procedure.

If the textual SQL procedure contains embedded SQL statements, the means for transforming a textual SQL procedure into a graphical diagram may automatically produce separate Aptitude SQL Rules corresponding with the embedded SQL statements, that are placed within the Aptitude SQL Procedure.

The SQL Visualizer may further comprise means for transforming a textual DDL command into a graphical diagram which represents the textual DDL command.

The graphical diagram which represents the textual DDL command may be an Aptitude SQL Procedure.

The graphical diagram which represents the textual SQL procedure and the graphical diagram which represents the textual DDL command can be both contained in the same Aptitude SQL Procedure.

The SQL Visualizer may further comprise a user interface comprising an editor into which a user may place textual elements prior to their conversion graphical form.

The editor can be arranged to receive textual SQL statements, DML statements, SQL procedures and/or DDL commands.

The user interface may comprise a dictionary selection control which allows a user to select a database used in the textual SQL statement, and to thereby provide a definition for the database for use in transforming the textual SQL statement into the graphical diagram which represents the textual SQL statement.

The dictionary selection control may allow selection of at least one of the following: Project EDF (External Data Format), Data Schema, and Database Server.

The SQL Visualizer may allow a user to create textual SQL statements and SQL procedures from graphical Aptitude SQL Rules and SQL Procedures.

The SQL Visualizer may allow a user to switch between textual and graphical representations of the same SQL statement or SQL procedure.

A user may be able to make changes to either the graphical or the textual representation of a SQL statement or SQL procedure, and the SQL Visualizer can then automatically generate the other of the graphical or the textual representation such that the same change is incorporated in both the textual representation and the graphical representation.

The graphical and textual representations may be automatically synchronized.

The invention can also be defined by any one of the following numbered paragraphs, which contain multiple dependencies suitable for providing support for claims in applications filed outside of the US.

1. A SQL Visualizer comprising means for transforming a textual SQL statement into a graphical diagram which represents said textual SQL statement.

2. A SQL Visualizer as defined in paragraph 1, wherein said graphical diagram which represents said textual SQL statement is an Aptitude SQL Rule.

3. A SQL Visualizer as defined in paragraph 1 or 2, which further comprises means for transforming a textual DML statement into a graphical diagram which represents said textual DML statement.

4. A SQL Visualizer as defined in paragraph 3, wherein said graphical diagram which represents said textual DML statement is an Aptitude SQL Rule.

5. A SQL Visualizer as defined in all of paragraphs 1 to 4, wherein said graphical diagram which represents said textual SQL statement and said graphical diagram which represents said textual DML statement are both contained in the same Aptitude SQL Rule.

6. A SQL Visualizer as defined in any preceding paragraph, which further comprises means for transforming a textual SQL procedure into a graphical diagram which represents said textual SQL procedure.

7. A SQL Visualizer as defined in paragraph 6, wherein said graphical diagram which represents said textual SQL procedure is an Aptitude SQL Procedure.

8. A SQL Visualizer as defined in paragraph 7, wherein if said textual SQL procedure contains embedded SQL statements, said means for transforming a textual SQL procedure into a graphical diagram automatically produces separate Aptitude SQL Rules corresponding with said embedded SQL statements, that are placed within the Aptitude SQL Procedure.

9. A SQL Visualizer as defined in any preceding paragraph, which further comprises means for transforming a textual DDL command into a graphical diagram which represents said textual DDL command.

10. A SQL Visualizer as defined in paragraph 9, wherein said graphical diagram which represents said textual DDL command is an Aptitude SQL Procedure.

11. A SQL Visualizer as defined in paragraph 10 when also dependent at least on paragraph 7, wherein said graphical diagram which represents said textual SQL procedure and said graphical diagram which represents said textual DDL command are both contained in the same Aptitude SQL Procedure.

12. A SQL Visualizer as defined in any preceding paragraph, which further comprises a user interface comprising an editor into which a user may place textual elements prior to their conversion graphical form.

13. A SQL Visualizer as defined in paragraph 12, wherein said editor is arranged to receive textual SQL statements, DML statements, SQL procedures and/or DDL commands.

14. A SQL Visualizer as defined in paragraph 12 or 13, wherein said user interface comprises a dictionary selection control which allows a user to select a database used in said textual SQL statement, and to thereby provide a definition for said database for use in transforming said textual SQL statement into said graphical diagram which represents said textual SQL statement.

15. A SQL Visualizer as defined in paragraph 14, wherein said dictionary selection control allows selection of at least one of the following: Project EDF (External Data Format), Data Schema, and Database Server.

16. A SQL Visualizer as defined in any preceding paragraph, which also allows a user to create textual SQL statements and SQL procedures from graphical Aptitude SQL Rules and SQL Procedures.

17. A SQL Visualizer as defined in paragraph 16, which allows a user to switch between textual and graphical representations of the same SQL statement or SQL procedure.

18. A SQL Visualizer as defined in any preceding paragraph, in which a user can make changes to either the graphical or the textual representation of a SQL statement or SQL procedure, and the SQL Visualizer can then automatically generate the other of the graphical or the textual representation such that the same change is incorporated in both the textual representation and the graphical representation.

19. A SQL Visualizer as defined in paragraph 18, wherein said graphical and textual representations are automatically synchronized.

The invention can also provide a method of providing a visualization of a textual SQL statement which comprises transforming the textual SQL statement into a graphical diagram which represents the textual SQL statement.

BRIEF DESCRIPTION OF THE FIGURES

FIG. 1 shows a toolbar of a SQL Visualizer described below;

FIGS. 2 to 12 are representations of screen shots, or partial screen shots, taken from the SQL Visualizer tool; and

FIG. 13 shows a computing device 60 suitable for running the Aptitude 3D software, and for implementing the Visualization tool described herein.

DETAILED DESCRIPTION

We first note that each feature disclosed or illustrated in the present specification may be incorporated in the invention, whether alone or in any appropriate combination with any other feature disclosed or illustrated herein.

We describe a SQL Visualization tool, hereinafter referred to as a SQL Visualizer, (which can be part of Microgen Aptitude as noted above). The SQL Visualizer can import database entities (SQL statements and procedures) in textual form to Microgen Aptitude and transform them from textual form to a graphical form in the proprietary format of Aptitude SQL Rules and Aptitude SQL Procedures.

The SQL Visualizer can provide the following functions:

Creating Aptitude SQL Rules diagrams from textual SQL statements; and/or

Creating Aptitude diagrammatic SQL Procedures, database tables, views and sequences from textual SQL procedures.

SQL Rules and SQL Procedures are two types of Aptitude graphical diagrams. Aptitude SQL Rules are used to graphically represent SQL select statements (querying the database) and DML (Data Manipulation Language) statements changing data—such as insert, update and delete statements.

Aptitude SQL Procedure diagrams are used to graphically represent database SQL procedures, which are not written in SQL. The stored procedures were invented to control the usage of Select and DML statements. They are close to a programming language (for instance, the stored procedure language for Oracle is called PL-SQL). They may call other stored procedures, SQL select statements, DML statements like insert, update, delete and also other database commands, like DDL (Data Definition Language) commands. DDL commands include e.g. statements creating database tables, views and also stored procedures. Databases have separate engines to execute SQL and stored procedures.

The new Aptitude functionality, i.e. the SQL Visualizer, makes it possible to convert the native database's SQL, DML, DDL and native stored procedure commands, which are in textual form, to a graphical representation used in Aptitude, as follows:

a) SQL select statements, and DML statements like insert, update and delete statements can be converted into Aptitude SQL Rules; and

b) Native stored procedure code and DDL commands creating stored procedures, tables or views can be converted into Aptitude SQL Procedures, which may contain blocks calling other Aptitude SQL Procedures, and blocks creating tables or views. Typically, database stored procedures contain a lot of embedded SQL select and DML (insert, update etc.) statements, which are converted by SQL Visualizer to SQL Rules, which are then referred (using graphical blocks) from the parent SQL Procedure diagram. In this way, the created Aptitude SQL Procedures (after the conversion) typically contain blocks representing calls to Aptitude SQL Rules (of select, insert, update etc. type), created as a result of the conversion of the DML parts of the master SQL Procedure.

The textual SQL Procedure usually contains embedded SQL Statements. For such SQL Statements we produce separate SQL Rules that are then used in the diagrammatic SQL Procedure blocks (e.g. Loop, Select, Insert, Update, Delete and Merge). SQL Procedures may also use other SQL Procedures. If we find such a call we first try to find the definition of that procedure (by its name) in the Project and use it in the diagrammatic Procedure block. If we do not find it we treat the call as an external one and we put its definition into the External Call Format and then use it in the diagrammatic Procedure block.

The SQL Visualizer can have a Toolbar 2, shown in FIG. 1. The Toolbar 2 can be accessible from a SQL Editor Toolbar within Aptitude. The SQL Visualizer Toolbar 2 can contain the following controls:

Database Type 4

Database Version 6

Database Entities Dictionary (Project, External Data Format, Data Schema or Database

Server) 8

Schema or Database Name (optional) 10

Owner (MS SQL Server, optional) 12

Command: Generate SQL Elements 14

Command: SQL Rule Update 16

Switch: Show/Hide Compilation Report 18

A SQL Editor 20 can be opened using an “Add New SQL Elements from SQL Statement” command 22 from a context menu 24 as shown in FIG. 2.

After opening the SQL Editor 20, the user must put the textual SQL statement into the SQL Editor 20 and then run the Generate SQL Elements command 14. Any compilation errors will appear in a Compilation Report. If there are no errors, then the Add New Element dialog will pop up, where the user can name the created SQL Rule or Procedure and then add it to an Aptitude Project.

SQL Visualizer takes the first SQL statement found in the SQL Editor, or the selected text, and translates this into the diagrammatic language. The resulting diagrammatic entities can be created one by one, or the whole script can be parsed.

We now describe creating a SQL Rule from a SQL Statement. To create a SQL Rule from a SQL Statement the user needs to open a special SQL Editor 20 as shown in FIG. 2.

The user puts the textual SQL Statement 26 into the SQL Editor 20 as shown in FIG. 3. Then the user can select the Dictionary control 8. The Dictionary provides definitions for a set of the database entities (tables) that might be used in the textual SQL Statement. These definitions are necessary to create an Aptitude SQL Rule from the SQL textual statement, because they provide information that is not present in the SQL statement (e.g. the SQL statement may use a table name but we need the table definition to create a functional Aptitude SQL Rule). The Dictionary is one of: Project, EDF (External Data Format), Data Schema, or Database Server, as shown in FIG. 3.

There is an assumption that the tables used in the SQL Statements 26 are already defined in the selected Dictionary 8. If the user selects EDF or Data Schema as the Dictionary, then the tables' definitions are taken from this single EDF or Data Schema. If the selected Dictionary is the Project, then table definitions are taken from one of the EDFs or Data Schemas present in the Project. If the user selects the Database Server as the Dictionary, then table definitions are taken directly from the Database or Database Schema 10 (selected by user).

To generate a new SQL Rule the user needs to press the Generate SQL Elements button 14 on the Toolbar 2.

The user then has an opportunity to name the SQL Rule (in this example the name “NewGeneratedSqlRule” is chosen by the user), and then the newly generated SQL Rule 28 is added to the Project, as shown in FIG. 4.

It is also possible to choose the Database Server as a Dictionary. In such a case the SQL Rule would not have references to the EDF's Tables. The Tables would be locally defined in the Table blocks of the SQL Rule as shown in FIG. 5.

We next describe SQL Rule Update. In the SQL Visualizer, it is possible to generate a textual SQL Statement from a diagrammatic SQL Rule, then to modify the SQL Statement as a text and then update the diagrammatic SQL Rule such that the changes made in the textual representation are included in the diagrammatic representation. This can be done by the following steps:

1. Generate a textual SQL Statement 30 from the graphical SQL Rule 32, as shown in FIG. 7;

2. Make changes to the text of the SQL Statement 30; and

3. Update the SQL Rule 32 to reflect changes made in the text of the SQL Statement 30, as shown in FIG. 7.

It is also possible to use the SQL Visualizer working directly with the database without the Aptitude Project environment, as shown in FIG. 8. In such a case, the User goes to the Workspace Explorer 34 and logs in to the database. Then the user expands the Database or Schema node 35 and then expands the Tables node, finally selecting one of the tables 36. The User can then drag the selected Table onto the SQL Editor 20 and then a simple SQL statement of the type defined by the combo Statement Type 37 is created by Aptitude. User can modify the statement using the SQL Editor. The statement type can be one of: Select, Inset, Update, Delete or Merge. The User can then convert the statement into diagrammatical SQL Rule 38 after running the Generate SQL Elements command 14.

We next describe creating a SQL Procedure Diagram from SQL Procedure text or a DDL Statement. The first steps are the same as for creating a new SQL Rule from a SQL Statement described above, but more objects are created (SQL Procedure, and accompanying SQL Rules, table, views and sequence definitions). The SQL Editor 20 is opened as described above for FIG. 2. When the diagrammatic SQL Procedure is created, the user is asked to give the new SQL Procedure a name, and in this example the name PRICE VALIDATION is chosen, as shown in FIG. 9.

The Generated diagrammatic SQL Procedure 40 is added to the Project together with its diagrammatic SQL Rules 42. The SQL Rules 42 are added as child nodes of the SQL Procedure 40 in the Project Folders View 44, as shown in FIG. 10.

We next describe importing an SQL Procedure from a database and creating a diagrammatic Aptitude SQL Procedure.

This function takes the textual SQL procedure from a database and converts it into a diagrammatic Aptitude SQL Procedure. This can be done in the following steps:

As described above for FIG. 2, the User opens a Project, right clicks the Project node in the Project Explorer and selects Add New SQL Elements from SQL Statement

This opens a new window called: “New SQL Elements from SQL Statement Input”, as shown in FIG. 2.

As shown in FIG. 11, the User goes to the Workspace Explorer 50 and logs in to the database. Then the user expands the Procedures node 52 (showing the procedures existing in the database), finds the Procedure the user wants to import to the Aptitude Project (in this example it is called PRICE VALIDATION), drags this Procedure and drops it into the editor window 20 opened in the previous step. The editor window 20 now contains the textual SQL Procedure 54, named PRICE VALIDATION.

The user executes Generate SQL Elements toolbar command 14. The user is asked for the name of the newly generated SQL Procedure, and in this example again chooses the name PRICE VALIDATION.

The generated diagrammatical Aptitude SQL Procedure 56 is added to the Aptitude Project, as shown in FIG. 12.

FIG. 13 shows a computing device 60, which may for example be a personal computer (PC), which is suitable for running the Aptitude 3D software. The computing device 60 comprises a display 62 for displaying information to the developer, a processor 64, a memory 66 and an input device 68 (for example a mouse and/or keyboard) for allowing the developer to input information. These elements are connected by a bus 70 via which information is exchanged between the components.

Having described the invention in detail and by reference to certain embodiments, it will be apparent that modifications and variations thereof are possible without departing from the scope of the invention. 

What is claimed is:
 1. A SQL Visualizer comprising means for transforming a textual SQL statement into a graphical diagram which represents said textual SQL statement.
 2. A SQL Visualizer as claimed in claim 1, wherein said graphical diagram which represents said textual SQL statement is an Aptitude SQL Rule.
 3. A SQL Visualizer as claimed in claim 1, which further comprises means for transforming a textual DML statement into a graphical diagram which represents said textual DML statement.
 4. A SQL Visualizer as claimed in claim 3, wherein said graphical diagram which represents said textual DML statement is an Aptitude SQL Rule.
 5. A SQL Visualizer as claimed claim 1, wherein said graphical diagram which represents said textual SQL statement and said graphical diagram which represents said textual DML statement are both contained in the same Aptitude SQL Rule.
 6. A SQL Visualizer as claimed in claim 1, which further comprises means for transforming a textual SQL procedure into a graphical diagram which represents said textual SQL procedure.
 7. A SQL Visualizer as claimed in claim 6, wherein said graphical diagram which represents said textual SQL procedure is an Aptitude SQL Procedure.
 8. A SQL Visualizer as claimed in claim 7, wherein if said textual SQL procedure contains embedded SQL statements, said means for transforming a textual SQL procedure into a graphical diagram automatically produces separate Aptitude SQL Rules corresponding with said embedded SQL statements, that are placed within the Aptitude SQL Procedure.
 9. A SQL Visualizer as claimed in claim 1, which further comprises means for transforming a textual DDL command into a graphical diagram which represents said textual DDL command.
 10. A SQL Visualizer as claimed in claim 9, wherein said graphical diagram which represents said textual DDL command is an Aptitude SQL Procedure.
 11. A SQL Visualizer as claimed in claim 7, wherein said graphical diagram which represents said textual DDL command is an Aptitude SQL Procedure and wherein said graphical diagram which represents said textual SQL procedure and said graphical diagram which represents said textual DDL command are both contained in the same Aptitude SQL Procedure.
 12. A SQL Visualizer as claimed in claim 1, which further comprises a user interface comprising an editor into which a user may place textual elements prior to their conversion graphical form.
 13. A SQL Visualizer as claimed in claim 12, wherein said editor is arranged to receive textual SQL statements, DML statements, SQL procedures and/or DDL commands.
 14. A SQL Visualizer as claimed in claim 12, wherein said user interface comprises a dictionary selection control which allows a user to select a database used in said textual SQL statement, and to thereby provide a definition for said database for use in transforming said textual SQL statement into said graphical diagram which represents said textual SQL statement.
 15. A SQL Visualizer as claimed in claim 14, wherein said dictionary selection control allows selection of at least one of the following: Project EDF (External Data Format), Data Schema, and Database Server.
 16. A SQL Visualizer as claimed in claim 1, which also allows a user to create textual SQL statements and SQL procedures from graphical Aptitude SQL Rules and SQL Procedures.
 17. A SQL Visualizer as claimed in claim 16, which allows a user to switch between textual and graphical representations of the same SQL statement or SQL procedure.
 18. A SQL Visualizer as claimed in claim 1, in which a user can make changes to either the graphical or the textual representation of a SQL statement or SQL procedure, and the SQL Visualizer can then automatically generate the other of the graphical or the textual representation such that the same change is incorporated in both the textual representation and the graphical representation.
 19. A SQL Visualizer as claimed in claim 18, wherein said graphical and textual representations are automatically synchronized.
 20. A SQL Visualizer comprising a transformer for transforming a textual SQL statement into a graphical diagram which represents said textual SQL statement. 